package com.jmxcfc.blfsc.cfca.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jmxcfc.blfsc.cfca.service.ISignRequestService;
import com.jmxcfc.blfsc.common.common.request.BaseRequest;
import com.jmxcfc.blfsc.common.common.response.BaseResponse;
import com.jmxcfc.blfsc.common.sign.SignRequest;
import com.jmxcfc.blfsc.common.sign.extend.SignExtend;
import com.jmxcfc.fs.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * cfca请求控制器
 */
@RestController
@RequestMapping("/cfca")
@Slf4j
public class CfcaRequestController {

    private ISignRequestService signRequestService;


    @Autowired
    public void setSignRequestService(ISignRequestService signRequestService) {
        this.signRequestService = signRequestService;
    }

    /**
     * 发送签章请求入口
     * @param request
     * @return
     */
    @PostMapping("/sign/request")
    public Result<BaseResponse<JSONObject>> request(@RequestBody BaseRequest<SignRequest<SignExtend>> request) {
        log.info("CFCA(中金国信)发送签章请求,请求参数:{}", JSON.toJSONString(request));
        BaseResponse<JSONObject> response = signRequestService.sendRequest(request);
        log.info("CFCA(中金国信)发送签章请求,响应结果:{}", JSON.toJSONString(response));
        return Result.success(response);
    }

}
